<?php
namespace wap\controllers;

use home\models\Timeline;
use Yii;
use yii\web\NotFoundHttpException;

/**
 * Class TimelineController
 *
 * @package wap\controllers
 */
class TimelineController extends BaseController
{

    /**
     * @return string
     */
    public function actionIndex()
    {
        $data = Timeline::find()->where(['status' => Timeline::STATUS_ACTIVE])->all();

        return $this->render('index', [
            'data' => $data,
        ]);
    }

    /**
     * @param $id
     *
     * @return string
     * @throws \yii\web\NotFoundHttpException
     */
    public function actionView($id)
    {
        $model = Timeline::findOne($id);

        if(!$model){
            throw new NotFoundHttpException('事记不存在！');
        }

        return $this->render('view', ['model' => $model]);
    }
}
